import java.util.ArrayList;
import java.util.List;

/** Create and modify an error table.<br>
 * Rep: The error table contains a list of each possible error that can be found in the 
 * code by the assembler. Each row in the table contains the error key, its description, 
 * and its severity.<br><br>
 * Change Log:<br>
 * 	- 04/27/09 - Tobin Chee<br>
 * 	- Changed error code 4 to signify an invalid start to an arithmetic expression in the operand field.<br>
 * 	- Changed descriptions on multiple errors to make the wording more consistent.<br><br>
 *  - 05/03/09 - Meghan Day<br>
 *  	- Added error messages.<br><br>
 *  - 05/05/09 - Tobin Chee<br>
 *  	- Added error messages<br>
 *  	- Updated error code 25 to say ON/OFF instead of YES/NO<br><br>
 *  - 05/05/09 - Meghan Day<br>
 *  	- Edited a few error message descriptions as they contained typos.<br><br>
 * 	- 05/05/09 - Ben Tarney<br>
 * 		- added error codes for specific cases used in my methods<br><br>
 * `- 05/0/09 - Tobin Chee<br>
 * 		- Added error codes to notify user of invalid symbol name<br><br>
 *  - 05/13/09 - Meghan Day<br>
 *  	- Fixed message of error 20, as it previously said "s not permitted with current operation."<br><br>
 *  - 05/17/09 - Meghan Day<br>
 *  	- Added error codes for operand out of range for DUMP and PWR.
 *  
 *  @author Meghan Day, Tobin Chee
 */
public class ErrorTable {
	/** ArrayList representation of error.
	 */
	private List<Integer> errorKey = new ArrayList<Integer>();
	/** ArrayList representation of description of error.
	 */
	private List<String> errorDescription = new ArrayList<String>();
	/** ArrayList representation of severity of error.
	 */
	private List<Assembler.ErrorSeverity> errorSeverity = new ArrayList<Assembler.ErrorSeverity>();
	
	/** Construct and populate an error table.
	 */
	public ErrorTable(){
		this.populateTable();
	}
	
	/** 
	 * Populates the static error table with all error values.<br><br>
	 */
	private void populateTable(){
		errorKey.add(0);
		errorDescription.add("Unexpected end of file. Program ended before FINSH directive was found");
		errorSeverity.add(Assembler.ErrorSeverity.FATAL);
		
		errorKey.add(1);
		errorDescription.add("Unexpected end of line");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(2);
		errorDescription.add("Invalid operand. Expecting single quote (')");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(3);
		errorDescription.add("Program should end with instruction \"FINSH\". There are extra lines of code");
		errorSeverity.add(Assembler.ErrorSeverity.WARNING);
		
		errorKey.add(4);
		errorDescription.add("Invalid operand. Expecting numeric expression to begin with '+', '-', predefined equated symbol or integer value in decimal ('/' and '*' not permitted)");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(5);
		errorDescription.add("Invalid operand. Expecting a separator or arithmetic operator after *");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(6);
		errorDescription.add("Invalid operand. Expecting a separator or arithmetic operator");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(7);
		errorDescription.add("Invalid operand. Current operand only accepts one operand (no commas permitted)");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		//Intended for use with ADRC and PRMLST. ADRC is the only operation that can accept arithmetic expressions with any symbol .
		//Most other operands should use error code 11 for this case
		errorKey.add(8);
		errorDescription.add("Invalid operand. Expecting symbol or valid decimal integer value");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(9);
		errorDescription.add("Invalid operand. Expecting operand field to begin with a symbol , sign(+ or -), indirect (%), or * notation");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(10);
		errorDescription.add("Invalid operand. Index register out of range (1 <= XR <= 7)");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(11);
		errorDescription.add("Invalid operand. Expecting valid 32-bit predefined equated symbol or integer in decimal.");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(12);
		errorDescription.add("Invalid third operand. IOWD flag out of range (0 <= IOWD_FLAG <= 3)");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(13);
		errorDescription.add("Invalid operand. Value out of range (-2^15 <= value <= 2^15 - 1)");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		//For use with ADRC only. Other operands should use code 22 because ADRC is the only operation that allows *+data_.
		errorKey.add(14);
		errorDescription.add("Invalid operand. Expecting symbol  or integer value after * + arithmetic_operator");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);	
		
		//For use with PRMID, because it is a warning. Most other instructions that expect a symbol will NOP and should be a severe error
		errorKey.add(15);
		errorDescription.add("Invalid operand. Expecting symbol label as an operand");
		errorSeverity.add(Assembler.ErrorSeverity.WARNING);
		
		errorKey.add(16);
		errorDescription.add("Invalid operand. Unnecessary operands after valid set of operands");
		errorSeverity.add(Assembler.ErrorSeverity.WARNING);
		
		errorKey.add(17);
		errorDescription.add("Invalid operand. Symbol is not defined.");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(18);
		errorDescription.add("Invalid operand. Expecting a valid 32-bit predefined equated symbol or integer in hexadecimal");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(19);
		errorDescription.add("Invalid operand. Expecting a valid 32-bit predefined equated symbol or integer in octal");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(20);
		errorDescription.add("Labels are not permitted with current operation.");
		errorSeverity.add(Assembler.ErrorSeverity.WARNING);
		
		errorKey.add(21);
		errorDescription.add("Invalid operand. DEC/HEX/OCTAL/ADDR value out of range (-2^31 <= value <= 2^31 - 1");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(22);
		errorDescription.add("Invalid operand. Expecting predefined equated symbol or integer value after \"*+\" or \"*-\"");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(23);
		errorDescription.add("Expecting whitespace between operation and operand field");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(24);
		errorDescription.add("Invalid operand. Memory address out of range (0 <= 4095)");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(25);
		errorDescription.add("Invalid operand. Expecting \"ON\" or \"OFF\". Non-case sensitive");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(26);
		errorDescription.add("Program length has exceeded 4096 words");
		errorSeverity.add(Assembler.ErrorSeverity.FATAL);
		
		errorKey.add(27);
		errorDescription.add("Invalid comment: A comment may only begin a line or follow an instruction");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(28);
		errorDescription.add("Invalid operand. Too many operands in arithmetic expression");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(29);
		errorDescription.add("Expecting operation after symbol + whitespace");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(30);
		errorDescription.add("Expecting whitespace between  and operation");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(31);
		errorDescription.add("Invalid label. Duplicate symbol name");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(32);
		errorDescription.add("Invalid operand. Expecting symbol  or integer value after \"%\"");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(33);
		errorDescription.add("Invalid operand. Expecting blank operand, predefined equated symbol or integer in decimal as the second operand");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(34);
		errorDescription.add("Line of code is too long. Length exceeds limit of 100 characters");
		errorSeverity.add(Assembler.ErrorSeverity.WARNING);
		
		errorKey.add(35);
		errorDescription.add("Invalid operand. Too many characters in string. Strings may contain up to 4 characters");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(36);
		errorDescription.add("Current instruction requires a label.");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(37);
		errorDescription.add("Expecting an instruction");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);

		errorKey.add(38);
		errorDescription.add("Too many characters in immediate string. Immediate strings may contain up to 2 characters");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);

		errorKey.add(39);
		errorDescription.add("Invalid operand. Expecting a comma.");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(40);
		errorDescription.add("Invalid instruction. PRMID already defined.");
		errorSeverity.add(Assembler.ErrorSeverity.WARNING);
		
		errorKey.add(41);
		errorDescription.add("Invalid operand. AVERT cannot accept a symbol previously defined by AVERT, EXTRN, EQU and BEGIN as an operand.");
		errorSeverity.add(Assembler.ErrorSeverity.WARNING);
		
		errorKey.add(42);
		errorDescription.add("Invalid operand. EXTRN cannot accept a previously defined symbol as an operand");
		errorSeverity.add(Assembler.ErrorSeverity.WARNING);
		
		errorKey.add(43);
		errorDescription.add("Invalid symbol. Symbol names must be no more than 24 characters long, consist of only alphanumeric characters, and begin with an alpha character.");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(44);
		errorDescription.add("Empty line of code.");
		errorSeverity.add(Assembler.ErrorSeverity.WARNING);
		
		errorKey.add(45);
		errorDescription.add("Invalid operand. Comma expected between operands.");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(46);
		errorDescription.add("Invalid operand. Expecting character string in single quotes or integer value after immediate symbol.");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(47);
		errorDescription.add("Invalid instruction. PRMLST instructions must follow consecutively after a valid PRMID instruction, and total PRMLST instructions may not exceed the param list length as defined by PRMID");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		//Begin Tobin's errors 51 - 70
		errorKey.add(51);
		errorDescription.add("Invalid instruction. Expecting PRMLST instruction. PRMID instruction must be followed by a parameter list of length given in it's second parameter.");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(52);
		errorDescription.add("Invalid operand. PRMID cannot define a predefined ");
		errorSeverity.add(Assembler.ErrorSeverity.WARNING);
		
		errorKey.add(53);
		errorDescription.add("Invalid label. Labels must be alpha-numeric strings beginning with an alpha and are limited to 24 characters in length");
		errorSeverity.add(Assembler.ErrorSeverity.WARNING);
		
		errorKey.add(54);
		errorDescription.add("Invalid operand. Symbol used in operand field not defined");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(55);
		errorDescription.add("Invalid operand. Cannot make a forward reference to an equated symbol");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(56);
		errorDescription.add("Invalid operand. Cannot use symbols defined by the BEGIN and PRMID directives as operands.");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(57);
		errorDescription.add("Invalid operand. The symbol used as an operand for AVERT is not defined in the program");
		errorSeverity.add(Assembler.ErrorSeverity.WARNING);
		
		errorKey.add(58);
		errorDescription.add("Invalid operation. The BEGIN directive can only be called once on the first line of the program.");
		errorSeverity.add(Assembler.ErrorSeverity.WARNING);
		
		errorKey.add(59);
		errorDescription.add("Invalid operand. Arithmetic operand out of range. Arithmetic expressions are limited to the use of 32-bit integer operands");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(60);
		errorDescription.add("Invalid operand. Expecting an predefined equated symbol or an integer in the range (0 <= value <= 4095)");
		errorSeverity.add(Assembler.ErrorSeverity.WARNING);
		
		errorKey.add(61);
		errorDescription.add("Invalid operand. Alternate start address designated by ALT must be greater than the original start address designated by BEGIN");
		errorSeverity.add(Assembler.ErrorSeverity.WARNING);		
		
		errorKey.add(62);
		errorDescription.add("Invalid operand. BSS only accepts operands in the range (0 <= value <= 4096)");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(63);
		errorDescription.add("Invalid instruction. Program did not begin with a legal BEGIN directive.");
		errorSeverity.add(Assembler.ErrorSeverity.FATAL);
		//End Tobin's errors 51 - 70		
		
		errorKey.add(71);
		errorDescription.add("Too many characters in string. Strings following immediates must be 0-2 characters in length");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(72);
		errorDescription.add("Invalid operand. * expected");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(73);
		errorDescription.add("Invalid operand. Format of integer value in data is incorrect");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(91);
		errorDescription.add("Invalid operand. Started with '/'. Must start with a number, equated symbol, or *, +, or -.");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(92);
		errorDescription.add("Invalid operand. Symbol is not equated.");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(93);
		errorDescription.add("Invalid operand. Expecting number or equated symbol after + or -.");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(94);
		errorDescription.add("Missing operand. Expecting valid predefined equated symbol or integer value in decimal.");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(95);
		errorDescription.add("Invalid operand. Expecting number or equated symbol after operator.");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(96);
		errorDescription.add("Missing operand. Expecting symbol or valid decimal integer value.");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(97);
		errorDescription.add("Invalid operand. Value out of range (0 <= value <= 2^15 - 1)");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);

		errorKey.add(98);
		errorDescription.add("Invalid operand. Value out of range (1 <= value <= 3)");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);

		errorKey.add(99);
		errorDescription.add("Invalid operand. Value out of range (0 <= value <= 10)");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);

		errorKey.add(100);
		errorDescription.add("Invalid operand. Cannot start with + or -.");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		//LinkerLoader errors span from error codes 200-300
		errorKey.add(200);
		errorDescription.add("Invalid text record. Expecting record to begin with \"T\".");
		errorSeverity.add(Assembler.ErrorSeverity.FATAL);
		
		errorKey.add(201);
		errorDescription.add("Invalid linking record. Duplicate symbol name.");
		errorSeverity.add(Assembler.ErrorSeverity.FATAL);
		
		errorKey.add(202);
		errorDescription.add("Invalid linking record. Expecting record to begin with \"L\".");
		errorSeverity.add(Assembler.ErrorSeverity.FATAL);
		
		errorKey.add(203);
		errorDescription.add("Invalid linking record. Module name field must match the module name field in the header record.");
		errorSeverity.add(Assembler.ErrorSeverity.FATAL);
		
		//TODO do we want any of these errors to be fatal?
		errorKey.add(204);
		errorDescription.add("Invalid end record. Expecting record to begin with \"E\".");
		errorSeverity.add(Assembler.ErrorSeverity.FATAL);
		
		errorKey.add(205);
		errorDescription.add("Invalid header record. Expecting record to begin with \"H\".");
		errorSeverity.add(Assembler.ErrorSeverity.FATAL);
		
		errorKey.add(206);
		errorDescription.add("Invalid text record. Expecting ARC field to contain a single 'A', 'R' or a 'C' character.");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(207);
		errorDescription.add("Invalid text record. Instruction references undefined external symbols.");
		errorSeverity.add(Assembler.ErrorSeverity.FATAL);
		
		errorKey.add(208);
		errorDescription.add("Invalid header record. Unexpected end of line.");
		errorSeverity.add(Assembler.ErrorSeverity.FATAL);
		
		errorKey.add(209);
		errorDescription.add("Invalid header record. Fields may only contain alpha-numeric characters in addition to {'-', '*', '/', ':'}.");
		errorSeverity.add(Assembler.ErrorSeverity.FATAL);
		
		errorKey.add(210);
		errorDescription.add("Invalid header record. Expecting separator between fields.");
		errorSeverity.add(Assembler.ErrorSeverity.FATAL);
		
		errorKey.add(211);
		errorDescription.add("Invalid header record. Programming language name field must be \"CSE7000\".");
		errorSeverity.add(Assembler.ErrorSeverity.FATAL);
		
		errorKey.add(212);
		errorDescription.add("Invalid header record. Expecting execution start address field to contain a 32-bit hex string.");
		errorSeverity.add(Assembler.ErrorSeverity.FATAL);
		
		errorKey.add(213);
		errorDescription.add("Invalid header record. Expecting number of text records field to contain a 32-bit hex string.");
		errorSeverity.add(Assembler.ErrorSeverity.FATAL);
		
		errorKey.add(214);
		errorDescription.add("Invalid header record. Expecting number of linking records field to contain a 32-bit hex string.");
		errorSeverity.add(Assembler.ErrorSeverity.FATAL);
		
		errorKey.add(215);
		errorDescription.add("Invalid header record. Expecting load address field to contain a valid 32-bit hex string in the range (0 <= load_addr <= 4095).");
		errorSeverity.add(Assembler.ErrorSeverity.FATAL);
		
		errorKey.add(216);
		errorDescription.add("Invalid header record. Expecting module length field to contain a valid 32-bit hex string in the range (0 <= load_addr <= 4096).");
		errorSeverity.add(Assembler.ErrorSeverity.FATAL);
		
		errorKey.add(217);
		errorDescription.add("Invalid header record. Expecting module name field to contain an alpha-numeric string of length <= 24.");
		errorSeverity.add(Assembler.ErrorSeverity.FATAL);
		
		errorKey.add(218);
		errorDescription.add("Invalid end record. Record contains too many fields.");
		errorSeverity.add(Assembler.ErrorSeverity.FATAL);
		
		errorKey.add(219);
		errorDescription.add("Invalid end record. Unexpected end of line.");
		errorSeverity.add(Assembler.ErrorSeverity.FATAL);
		
		errorKey.add(220);
		errorDescription.add("Invalid end record. Fields may only contain alpha-numeric characters in addition to {'-', '*', '/', ':'}.");
		errorSeverity.add(Assembler.ErrorSeverity.FATAL);
		
		errorKey.add(221);
		errorDescription.add("Invalid end record. Expecting separator between fields.");
		errorSeverity.add(Assembler.ErrorSeverity.FATAL);
		
		errorKey.add(222);
		errorDescription.add("Invalid end record. Total number of records field does not match actual total number of records.");
		errorSeverity.add(Assembler.ErrorSeverity.FATAL);

		//note the only difference between errors 223 and 224 is that one is SEVERE and the other is FATAL
		errorKey.add(223);
		errorDescription.add("Invalid text record. Expecting separator between fields.");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(224);
		errorDescription.add("Invalid text record. Expecting separator between fields.");
		errorSeverity.add(Assembler.ErrorSeverity.FATAL);
		
		errorKey.add(225);
		errorDescription.add("Invalid text record. Fields may only contain alpha-numeric characters in addition to {'-', '*', '/', ':'}.");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(226);
		errorDescription.add("Invalid text record. Fields may only contain alpha-numeric characters in addition to {'-', '*', '/', ':'}.");
		errorSeverity.add(Assembler.ErrorSeverity.FATAL);
		
		errorKey.add(227);
		errorDescription.add("Invalid text record. Module name field must match the module name field in the header record.");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(228);
		errorDescription.add("Invalid text record. Record contains too many fields.");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(229);
		errorDescription.add("Invalid text record. Expecting instruction code field to be a valid 32-bit hex string.");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(230);
		errorDescription.add("Invalid text record. Expecting address field to be a valid 32-bit hex string in the range (0 <= addr <= 4095).");
		errorSeverity.add(Assembler.ErrorSeverity.FATAL);
		
		errorKey.add(231);
		errorDescription.add("Invalid text record. Expecting sign field to contain a single sign symbol (\"+\", \"-\").");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(232);
		errorDescription.add("Invalid text record. Expecting arithmetic operator field to be a single arithmetic operator (\"+\", \"-\", \"*\", \"/\").");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(233);
		errorDescription.add("Invalid text record. Expecting ARC field to be empty, or contain an 'A', 'R', 'C'.");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(234);
		errorDescription.add("Invalid text record. Expecting separator between fields.");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(235);
		errorDescription.add("Invalid text record. For the set of fields {ARC, sign, arithmetic operator, reference}, if any one field is non-empty, then all fields must be non-empty.");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(236);
		errorDescription.add("Invalid text record. For the set of fields {ARC, sign, arithmetic operator, reference}, if any one field is empty, then all fields must be empty.");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(237);
		errorDescription.add("Invalid text record. Unexpected end of line.");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(238);
		errorDescription.add("Invalid text record. Expecting symbol label field to be an alpha-numeric string of length <= 24.");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(239);
		errorDescription.add("Invalid text record. Expecting reference field to be a valid 32-bit hex string.");
		errorSeverity.add(Assembler.ErrorSeverity.SEVERE);
		
		errorKey.add(240);
		errorDescription.add("Invalid linking record. Module name field must match the module name field in the header record.");
		errorSeverity.add(Assembler.ErrorSeverity.FATAL);
		
		errorKey.add(241);
		errorDescription.add("Invalid linking record. Record contains too many fields.");
		errorSeverity.add(Assembler.ErrorSeverity.FATAL);
		
		errorKey.add(242);
		errorDescription.add("Invalid linking record. Fields may only contain alpha-numeric characters in addition to {'-', '*', '/', ':'}.");
		errorSeverity.add(Assembler.ErrorSeverity.FATAL);
		
		errorKey.add(243);
		errorDescription.add("Invalid linking record. Unexpected end of line.");
		errorSeverity.add(Assembler.ErrorSeverity.FATAL);
		
		errorKey.add(244);
		errorDescription.add("Invalid linking record. Expecting separator between fields.");
		errorSeverity.add(Assembler.ErrorSeverity.FATAL);
		
		errorKey.add(245);
		errorDescription.add("Invalid text record. Duplicate instruction load address. Load address is already used by another instruction.");
		errorSeverity.add(Assembler.ErrorSeverity.FATAL);
		
		errorKey.add(246);
		errorDescription.add("Invalid text record. Unexpected end of line.");
		errorSeverity.add(Assembler.ErrorSeverity.FATAL);
		
		errorKey.add(247);
		errorDescription.add("Memory overflow. Adjusted instruction load address is out of range (0 <= addr <= 4095).");
		errorSeverity.add(Assembler.ErrorSeverity.FATAL);
	}
	
	/** Finds the severity of an error with the given error code.<br><br>
	 * Requires: error is defined in table.
	 * @param errorCode Integer representation of error.
	 * @return Severity of error.
	 */
	public Assembler.ErrorSeverity getErrorSeverity(int errorCode){
		int index = errorKey.indexOf(errorCode);
		return errorSeverity.get(index);
	}
	
	/** Finds the description of an error.<br><br>
	 * Requires: error is defined.
	 * @param errorCode Integer representation of error.
	 * @return Description of error.
	 */
	public String getErrorDescription(int errorCode){
		int index = errorKey.indexOf(errorCode);
		return errorDescription.get(index);
	}
	
	/** Test whether an error is defined in the table.
	 * @param errorCode Integer representation of error to test for.
	 * @return True if error is defined, otherwise return false.
	 */
	public Boolean errorIsDefined(int errorCode){
		return errorKey.contains(errorCode);
	}
}
